2017年信息学奥赛NOIP提高组
初赛
更早
2023-09-02 14:52:33
30次
一、单选题
欢乐喷球:儿童游乐场有个游戏叫“欢乐喷球”,正方形场地中心能不断喷出彩色乒乓球,以场地中心为圆心还有个圆形轨道,轨道上有一列小火车在匀速运动,火车有六节车厢。假设乒乓球等概率落到正方形场地的每个地点,包括火车车厢。小朋友玩这个游戏时,只能坐在同一个火车车厢里,可以在自己的车厢里捡落在该车厢内的所有乒乓球,每个人每次游戏有三分钟时间,则一个小朋友独自玩一次游戏期望可以得到( )个兵乓球。假设乒乓球喷出的速度为2个/秒,每节车厢的面积是整个场地面积的1/20。

| A. 60 |
B. 108 |
| C. 18 |
D. 20 |
【知识点】 信息学NOIP提高组
有正实数构成的数字三角形排列形式如图所示。

第一行的数为a11;第二行的数从左到右依次为a21,a,22;…第n行的数为an1, an2,…. ann。从a11开始,每一行的数aij只有两条边可以分别通向下一行的两个数a(i+1)j和a(i+1)(j+1)。用动态规划算法找出一条从a11向下通到an1,an2.…,ann中某个数的路径,使得该路径上的数之和达到最大。
令C[i,j]是从a11到aij的路径上的数的最大和,并且C[i,0]=C[0,j]=0,则C[i,j]=( )。
| A. max{C[i-1,j-1],C[i-1,j]}+ aij |
B. C[i-1,j-1]+C[i-1,j] |
| C. max{C[i-1,j-1],C[i-1,j]}+1 |
D. max{C[i,j-1],C[i-1,j]}+ aij |
【知识点】 信息学NOIP提高组
二、多选题
三、填空题
四、简答题
(最长路径)给定一个有向无环图,每条边长度为1,求图中的最长路径长度。(第五空2分,其余3分)
输入:第一行是结点数n(不超过100)和边数m,接下来m行,每行两个整数a,b,表示从结点a到结点b有一条有向边。结点标号从0到(n-1)。
输出:最长路径长度。
提示:先进行拓扑排序,然后按照拓扑序计算最长路径。
#include <iostream>
using namespace std;
int n, m, i, j, a, b, head, tail, ans;
int graph[100][100]; // 用邻接矩阵存储图
int degree[100]; // 记录每个结点的入度
int len[100]; // 记录以各结点为终点的最长路径长度
int queue[100]; // 存放拓扑排序结果
int main() {
cin >> n >> m;
for (i = 0; i < n; i++)
for (j = 0; j < n; j++)
graph[i][j] = 0;
for (i = 0; i < n; i++)
degree[i] = 0;
for (i = 0; i < m; i++) {
cin >> a >> b;
graph[a][b] = 1;
(1) ;
}
tail = 0;
for (i = 0; i < n; i++)
if ( (2) ) {
queue[tail] = i;
tail++;
}
head = 0;
while (tail < n - 1) {
for (i = 0; i < n; i++)
if (graph[queue[head] ][i] == 1) {
(3) ;
if (degree[i] == 0) {
queue[tail] = i;
tail++;
}
}
(4) ;
}
ans = 0;
for (i = 0; i < n; i++) {
a = queue[i];
len[a] = 1;
for (j = 0; j < n; j++)
if (graph[j][a] == 1 && len[j] + 1 > len[a])
len[a] = len[j] + 1;
if ( (5) )
ans = len[a];
}
cout << ans << endl;
return 0;
}
【知识点】 信息学NOIP提高组
#include <iostream>
using namespace std;
int main() {
int n, m;
cin >> n >> m;
int x = 1;
int y = 1;
int dx = 1;
int dy = 1;
int cnt = 0;
while (cnt != 2) {
cnt = 0;
x = x + dx;
y = y + dy;
if (x == 1 || x == n) {
++cnt;
dx = -dx;
}
if (y == 1 || y == m) {
++cnt;
dy = -dy;
}
}
cout << x << " " << y << endl;
return 0;
}输入1:4 3
输出1:_________(2 分)
输入2:2017 1014
输出 2:_________(3 分)
输入3:987 321
输出3:_________(3 分)
【知识点】 信息学NOIP提高组
#include <iostream>
using namespace std;
int n, s, a[100005], t[100005], i;
void mergesort(int l, int r) {
if (l == r)
return;
int mid = (l + r) / 2;
int p = l;
int i = l;
int j = mid + 1;
mergesort(l, mid);
mergesort(mid + 1, r);
while (i <= mid && j <= r) {
if (a[j] < a[i]) {
s += mid - i + 1;
t[p] = a[j];
p++;
j++;
}
else {
t[p] = a[i];
p++;
i++;
}
}
while (i <= mid) {
t[p] = a[i];
p++;
i++;
}
while (j <= r) {
t[p] = a[j];
p++;
j++;
}
for (i = l; i <= r; i++)
a[i] = t[i];
}
int main() {
cin >> n;
for (i = 1; i <= n; i++)
cin >> a[i];
mergesort(1, n);
cout << s << endl;
return 0;
}输入:
6
2 6 3 4 5 1
输出:_________
【知识点】 信息学NOIP提高组
#include <iostream>
using namespace std;
int g(int m, int n, int x) {
int ans = 0;
int i;
if (n == 1)
return 1;
for (i = x; i <= m / n; i++)
ans += g(m - i, n - 1, i);
return ans;
}
int main() {
int t, m, n;
cin >> m >> n;
cout << g(m, n, 0) << endl;
return 0;
}输入:8 4
输出:_________
【知识点】 信息学NOIP提高组
#include <iostream>
using namespace std;
int main() {
int n, i, j, x, y, nx, ny;
int a[40][40];
for (i = 0; i < 40; i++)
for (j = 0; j < 40; j++)
a[i][j] = 0;
cin >> n;
y = 0; x = n - 1;
n = 2 * n - 1;
for (i = 1; i <= n * n; i++) {
a[y][x] = i;
ny = (y - 1 + n) % n;
nx = (x + 1) % n;
if ((y == 0 && x == n - 1) || a[ny][nx] != 0)
y = y + 1;
else { y = ny; x = nx; }
}
for (j = 0; j < n; j++)
cout << a[0][j] << " ";
cout << endl;
return 0;
}输入:3
输出:_________
【知识点】 信息学NOIP提高组
(大整数除法)给定两个正整数p和q,其中p不超过10100,q不超过100000,
求p除以q的商和余数。(第一空2分,其余3分)
输入:第一行是p的位数n,第二行是正整数p,第三行是正整数q。
输出:两行,分别是p除以q的商和余数。
#include <iostream>
using namespace std;
int p[100];
int n, i, q, rest;
char c;
int main() {
cin >> n;
for (i = 0; i < n; i++) {
cin >> c;
p[i] = c - '0';
}
cin >> q;
rest = (1) ;
i = 1;
while ( (2) && i < n) {
rest = rest * 10 + p[i];
i++;
}
if (rest < q)
cout << 0 << endl;
else {
cout << (3) ;
while (i < n) {
rest = (4) ;
i++;
cout << rest / q;
}
cout << endl;
}
cout << (5) << endl;
return 0;
}
【知识点】 信息学NOIP提高组




